﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LibraryO2S;
using System.IO;
using System.Data;

public partial class Administrator_locationedit : System.Web.UI.Page
{
    private LocationController objLocation = new LocationController();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {
                string id = Request.QueryString["id"].ToString();
                DataTable dtLocation = objLocation.GetByID(id);
                txtName.Text = dtLocation.Rows[0]["LOCATIONNAME"].ToString();
                txtDescription.Text = dtLocation.Rows[0]["DESCRIPTION"].ToString();
                txtPrice.Text = dtLocation.Rows[0]["PRICE"].ToString();
                string status = dtLocation.Rows[0]["STATUS"].ToString();
                if (status == "1")
                {
                    chkStatus.Checked = true;
                }
                else
                {
                    chkStatus.Checked = false;
                }
            }
            catch
            {
            }
        }
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        string id = Request.QueryString["id"].ToString();
        string name = txtName.Text;
        string desc = txtDescription.Text;
        string price = txtPrice.Text.Trim();
        string status = "";
        if (chkStatus.Checked == true)
        {
            status = "1";
        }
        else
        {
            status = "0";
        }
        bool a = objLocation.Update(id, name, desc, price, status);
        if (a == true)
        {
            Response.Redirect("location.aspx");
        }
    }
}